{// 引入标签库 }
<tagLib name="html" />
<include file="Public:header" />
<load href='__TMPL__Common/js/jquery.bgiframe.js' />
<load href='__TMPL__Common/js/jquery.weebox.js' />
<load href='__TMPL__Common/style/weebox.css' />
<script type="text/javascript" src="__TMPL__Common/js/calendar/calendar.php?lang=zh-cn" ></script>
<load href='__TMPL__Common/js/calendar/calendar.css' />
<load href='__TMPL__Common/js/calendar/calendar.js' />
<script type="text/javascript">
	function preview(id)
	{
		window.open("__ROOT__/index.php?ctl=deal&id="+id+"&preview=1");
	}
	
	function op_status(id){
		var url = ROOT+"?"+VAR_MODULE+"="+MODULE_NAME+"&"+VAR_ACTION+"=op_generation_repay_status&id="+id;
		$.weeboxs.open(url,{contentType:'ajax',showButton:false,title:"账单操作",width:600});
	}
	
	function repay_plan(id,l_key)
	{
		var query=new Object();
		query.deal_id = id;
		query.l_key = l_key;
		query.obj = "#J_view_repay_plan";
		query.p = 1;
		$.ajax({
			url:ROOT+"?"+VAR_MODULE+"="+MODULE_NAME+"&"+VAR_ACTION+"=repay_plan_a", 
			data:query,
			type:"post",
			dataType:"json",
			success:function(result){
				if(result.status==1){
					$.weeboxs.open('<div id="J_view_repay_plan">'+result.info+'</div>',{contentType:'text',showButton:false,title:"还款详情",width:600});
				}
				else{
					alert(result.info);
				}
			},
			error:function(){
				alert("请求数据失败");
			}
		});
	}
	
	function getLoanItem(obj,deal_id,l_key,p){
		var query=new Object();
		query.deal_id = deal_id;
		query.l_key = l_key;
		query.obj = obj;
		query.p = p;
		$.ajax({
			url:ROOT+"?"+VAR_MODULE+"="+MODULE_NAME+"&"+VAR_ACTION+"=repay_plan_a", 
			data:query,
			type:"post",
			dataType:"json",
			success:function(result){
				if(result.status==1){
					$(obj).html(result.info);
				}
				else{
					alert(result.info);
				}
			},
			error:function(){
				alert("请求数据失败");
			}
		});
	}
	function export_csv_generation()
	{
		var inputs = $(".search_row").find("input");
		var selects = $(".search_row").find("select");
		var param = '';
		for(i=0;i<inputs.length;i++)
		{
			if(inputs[i].name!='m'&&inputs[i].name!='a')
			param += "&"+inputs[i].name+"="+$(inputs[i]).val();
		}
		for(i=0;i<selects.length;i++)
		{
			param += "&"+selects[i].name+"="+$(selects[i]).val();
		}
		var url= ROOT+"?"+VAR_MODULE+"="+MODULE_NAME+"&"+VAR_ACTION+"=export_csv_generation";
		location.href = url+param;
	}
</script>
<php>
	function repay_plan($id,$deal){
		return '<a href="javascript:repay_plan('.$deal['deal_id'].','.$deal['l_key'].');">还款详情</a>&nbsp;';
	}
	function preview($id,$deal){
		return '<a href="javascript:preview('.$deal['deal_id'].');">'.msubstr($deal['name']).'</a>';
	}	
	
</php>
<style type="text/css">
	#J_view_repay_plan th{ color:#fff; padding:5px 0}
</style>
<div class="main">
<div class="main_title">{$main_title}</div>
<div class="blank5"></div>
<div class="search_row">
	<form name="search" action="__APP__" method="get" id="ThreeGetForm">	
		{%DEAL_NAME}：<input type="text" class="textbox" name="name" value="{:trim($_REQUEST['name'])}" />
		贷款人：
		<input type="text" class="textbox" name="user_name" value="{:trim($_REQUEST['user_name'])}" size="10" />
		{%CATE_TREE}：
		<select name="cate_id">
			<option value="0" <if condition="intval($_REQUEST['cate_id']) eq 0">selected="selected"</if>>{%NO_SELECT_CATE}</option>
			<foreach name="cate_tree" item="cate_item">
				<option value="{$cate_item.id}" <if condition="intval($_REQUEST['cate_id']) eq $cate_item['id']">selected="selected"</if>>{$cate_item.title_show}</option>
			</foreach>
		</select>
		收款状态：
		<select name="status">
			<option value="0" <if condition="intval($_REQUEST['status']) eq 0">selected="selected"</if>>所有状态</option>
			<option value="1" <if condition="intval($_REQUEST['status']) eq 1">selected="selected"</if>>垫付待还款</option>
			<option value="2" <if condition="intval($_REQUEST['status']) eq 2">selected="selected"</if>>垫付已还款</option>
		</select>
		账单状态
		<select name="deal_status">
			<option value="0" <if condition="intval($_REQUEST['deal_status']) eq 0">selected="selected"</if>>所有的</option>
			<option value="1" <if condition="intval($_REQUEST['deal_status']) eq 1">selected="selected"</if>>正常的</option>
			<option value="2" <if condition="intval($_REQUEST['deal_status']) eq 2">selected="selected"</if>>坏账的</option>
		</select>
		
		<div class="blank5"></div>
		还款时间：
		<input type="text" class="textbox" name="begin_time" id="begin_time" value="{:trim($_REQUEST['begin_time'])}" onfocus="return showCalendar('begin_time', '%Y-%m-%d', false, false, 'begin_time');" />
		-
		<input type="text" class="textbox" name="end_time" id="end_time" value="{:trim($_REQUEST['end_time'])}" onfocus="return showCalendar('end_time', '%Y-%m-%d', false, false, 'end_time');"  />
		
		
		<input type="hidden" value="Deal" name="m" />
		<input type="hidden" value="generation_repay" name="a" />
		<input type="submit" class="button" value="{%SEARCH}" />
		<input type="button" class="button" value="{%EXPORT}" onclick="export_csv_generation();" /> 
	</form>
</div>
<div class="blank5"></div>
<html:list 
	id="dataTable" 
	style="dataTable" 
	name="deal" 
	action="true" 
	datasource="list" 
	show="id:{%ID}|50px
		,name|preview=$deal:{%DEAL_NAME}
		,l_key_index:第几期
		,cate_id|get_deal_cate_name:{%DEAL_CATE}
		,user_id|get_user_name:借款人
		,mobile:手机号码
		,repay_money|format_price:金额[垫]
		,manage_money|format_price:管理费[垫]
		,impose_money|format_price:逾期费[垫]
		,manage_impose_money|format_price:逾期管理费[垫]
		,total_money|format_price:总垫付
		,repay_time|to_date='Y-m-d':还款日
		,create_time_format:垫付时间
		,admin_id|get_admin_name:操作管理员
		,agency_name:操作机构
		,site_bad_status:账单状态
		,status_format:收款状态"
	actionlist="id|repay_plan=$deal,op_status:操作"
	actionwidth="98px" /> 

<div class="blank5"></div>
<div class="page">{$page}</div>
</div>
<include file="Public:footer" />